package yodoo

import "github.com/gin-gonic/gin"

const ERRCODE_OK = 0
const ERRCODE_INTERNALERR = -1
const ERRCODE_ACCOUNT_NOTEXIST = 300001
const ERRCODE_ACCOUNT_AUTHFAILED = 300002

func LoginSuccess(c *gin.Context) {
	c.JSON(200, NewResponse(ERRCODE_OK, "ok", ""))
}

func LoginFail(c *gin.Context) {
	c.JSON(200, NewResponse(ERRCODE_ACCOUNT_AUTHFAILED, "授权失败", ""))
}

func LoginError(c *gin.Context) {
	c.JSON(200, NewResponse(ERRCODE_INTERNALERR, "内部错误", ""))
}

func NewResponse(code int, msg string, encrypt string) gin.H {
	pack := gin.H{
		"errcode": code,
		"errmsg":  msg,
		"encrypt": encrypt,
	}
	return pack
}
